<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background: url(./img/1.jpg)no-repeat;
            background-size: 100%;
        }

        #box {
            width: 1200px;
            height: 400px;
            margin: 100px auto;
        }

        img {
            width: 195px;
            height: 200px;
            padding-top: 100px;
        }
    </style>
</head>

<body>
    <div id="box">
        <img src="./img/1.jpg" alt="">
        <img src="./img/2.jpg" alt="">
        <img src="./img/3.jpg" alt="">
        <img src="./img/4.jpg" alt="">
        <img src="./img/5.jpg" alt="">
        <img src="./img/8.jpg" alt="">
    </div>

</body>
<script>
    var img = document.getElementsByTagName('img')
    console.log(img);
    for (var i = 0; i < img.length; i++) {
        img[i].onclick = function () {
            document.body.style.backgroundImage = 'url(' + this.src + ')'
        }

    }
</script>

</html>